package com.fxl.majiang.room;

import com.fxl.majiang.enums.TilesEnum;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fengxinglei
 * @date 2022/8/5 11:42
 * @description 胡的牌组
 */
@Data
public class HuData {

    // abc牌组
    private List<List<TilesEnum>> abcGroup;

    // ddd牌组
    private List<List<TilesEnum>> dddGroup;

    // 将牌
    private List<TilesEnum> jiang;

    /**
     * 是否有将牌
     * @return
     */
    public boolean haveJiang() {
        return !CollectionUtils.isEmpty(jiang) && jiang.size() == 2;
    }

    public void addToABCGroup(List<TilesEnum> abc) {
        if (CollectionUtils.isEmpty(abcGroup)) {
            abcGroup = new ArrayList<>();
        }
        abcGroup.add(abc);
    }

    public void addToDDDGroup(List<TilesEnum> ddd) {
        if (CollectionUtils.isEmpty(dddGroup)) {
            dddGroup = new ArrayList<>();
        }
        dddGroup.add(ddd);
    }
}
